package com.ques.service.impl;

import com.ques.dao.QuestionDao;
import com.ques.entity.QueryParam;
import com.ques.pojo.Question;
import com.ques.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zq  2020-01-07
 */
@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionDao questionDao ;


    @Override
    public Question createQuestion(Question question) {
        Question question1 = questionDao.insertQuestionnaire(question);
        return question1;
    }
// 分页
    @Override
    public List<Question> getAllQuestion(QueryParam queryParam) {
        List<Question> questions = questionDao.selectAllQuestion(queryParam);

        return questions;
    }

    @Override
    public Question updateQuestion(Question question) {
        questionDao.updateQuestion(question) ;
        return null;
    }

    @Override
    public Question getQuestionById(String page) {

        return  questionDao.selectQuestionById(page);
    }

    @Override
    public boolean updateQuestionStatus(String questionId, boolean status) {
       boolean flag =  questionDao.updateQuestionStatus(questionId , status) ;
        return flag;
    }

    @Override
    public long deleteQuestion(String[] questionIds) {
        if(questionIds == null || questionIds.length == 0 ){
            return 0 ;
        }else{

            return   questionDao.deleteQuestion(questionIds) ;
        }
    }
}
